home *** CD-ROM | disk | FTP | other *** search
- /*
- ==============================================================================
-
- Astronaut, and Redneck NPC
-
- ==============================================================================
- */
-
- #include "g_local.h"
- #include "npc_astronaut.h"
-
-
- static int sound_pain;
- static int sound_die;
- static int sound_idle;
- static int sound_talk;
- static int sound_talk2;
- static int sound_talk3;
- static int sound_sight;
- static int sound_search;
-
- void astronaut_standstill (edict_t *self);
- void astronaut_fidget (edict_t *self);
- void astronaut_talk (edict_t *self);
-
- void astronaut_search (edict_t *self)
- {
- gi.sound (self, CHAN_VOICE, sound_search, 1, ATTN_NORM, 0);
- }
-
- mframe_t astronaut_frames_stand [] =
- {
- ai_stand, 0, astronaut_fidget,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
-
- };
- mmove_t astronaut_move_stand = {FRAME_stand01, FRAME_stand09, astronaut_frames_stand, NULL};
-
- void astronaut_stand (edict_t *self)
- {
- self->monsterinfo.currentmove = &astronaut_move_stand;
- }
-
- mframe_t astronaut_frames_fidget [] =
- {
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
-
- };
- mmove_t astronaut_move_fidget = {FRAME_con01, FRAME_con19, astronaut_frames_fidget, astronaut_stand};
-
- void astronaut_fidget (edict_t *self)
- {
- if (self->spawnflags & 0) // don't want him to be at a console.
- return;
- if (self->monsterinfo.aiflags & AI_STAND_GROUND)
- return;
- if (random() > 0.25)
- return;
-
- self->monsterinfo.currentmove = &astronaut_move_fidget;
- gi.sound (self, CHAN_VOICE, sound_idle, 1, ATTN_IDLE, 0);
- }
-
- mframe_t astronaut_frames_still [] =
- {
- ai_still, 0, NULL,
- ai_still, 0, NULL,
- ai_still, 0, NULL,
- ai_still, 0, NULL,
- ai_still, 0, NULL,
- ai_still, 0, NULL,
- ai_still, 0, NULL,
- ai_still, 0, NULL,
- ai_still, 0, NULL,
- ai_still, 0, NULL
-
- };
- mmove_t astronaut_move_standstill = {FRAME_stand01, FRAME_stand09, astronaut_frames_still, astronaut_standstill};
-
- void astronaut_standstill (edict_t *self)
- {
- self->monsterinfo.currentmove = &astronaut_move_standstill;
- }
-
- mframe_t astronaut_frames_walk [] =
- {
- ai_run, 0.0, NULL,
- ai_run, 3.3, NULL,
- ai_run, 8.9, NULL,
- ai_run, 10.0, NULL,
- ai_run, 0.0, NULL,
- ai_run, 0.0, NULL,
- ai_run, 0.0, NULL,
- ai_run, 3.0, NULL,
- ai_run, 8.0, NULL,
- ai_run, 10.0, NULL,
- ai_run, 0.0, NULL,
- ai_run, 0.0, NULL,
- };
- mmove_t astronaut_move_walk = {FRAME_walk01, FRAME_walk12, astronaut_frames_walk, NULL};
-
- mframe_t astronaut_frames_walking [] =
- {
- ai_run, 0.0, NULL,
- ai_run, 3.3, NULL,
- ai_run, 8.9, NULL,
- ai_run, 10.0, NULL,
- ai_run, 0.0, NULL,
- ai_run, 0.0, NULL,
- ai_run, 0.0, NULL,
- ai_run, 3.0, NULL,
- ai_run, 8.0, NULL,
- ai_run, 10.0, NULL,
- ai_run, 0.0, NULL,
- ai_run, 0.0, NULL,
- };
- mmove_t astronaut_move_walking = {FRAME_walk01, FRAME_walk12, astronaut_frames_walking, NULL};
-
- void astronaut_walk (edict_t *self)
- {
- self->monsterinfo.currentmove = &astronaut_move_walk;
- }
-
- void astronaut_walking (edict_t *self)
- {
- self->monsterinfo.currentmove = &astronaut_move_walking;
- }
-
-
- mframe_t astronaut_frames_run1 [] =
- {
- ai_run, 13, NULL,
- ai_run, 25, NULL,
- ai_run, 0, NULL,
- ai_run, 5, NULL,
- ai_run, 14, NULL,
- ai_run, 24, NULL,
- ai_run, 0, NULL,
- ai_run, 5, NULL
- };
- mmove_t astronaut_move_run1 = {FRAME_run01, FRAME_run08, astronaut_frames_run1, NULL};
-
- void astronaut_run (edict_t *self)
- {
- if (self->monsterinfo.aiflags & AI_STAND_GROUND)
- self->monsterinfo.currentmove = &astronaut_move_stand;
- else
- self->monsterinfo.currentmove = &astronaut_move_run1;
- }
- mframe_t redneck_frames_run1 [] =
- {
- ai_run, 0, NULL,
- ai_run, 0, NULL,
- ai_run, 0, NULL,
- ai_run, 0, NULL,
- ai_run, 0, NULL,
- ai_run, 0, NULL,
- ai_run, 0, NULL,
- ai_run, 0, NULL,
- ai_run, 0, NULL
- };
- mmove_t redneck_move_run1 = {FRAME_stand01, FRAME_stand09, redneck_frames_run1, NULL};
-
- void redneck_run (edict_t *self)
- {
- if (self->monsterinfo.aiflags & AI_STAND_GROUND)
- self->monsterinfo.currentmove = &astronaut_move_stand;
- else
- self->monsterinfo.currentmove = &redneck_move_run1;
- }
- void astronaut_run_after_talk (edict_t *self)
- {
- if (random() < 0.8)
- self->monsterinfo.currentmove = &astronaut_move_run1;
- else
- self->monsterinfo.currentmove = &astronaut_move_walking;
- }
-
- void open_mouth(edict_t *self)
- {
- self->s.skinnum = 1;
- }
-
- void close_mouth(edict_t *self)
- {
- self->s.skinnum = 0;
- }
-
- void astronautTalk(edict_t *self)
- {
- if (self->spawnflags & 1)
- gi.sound(self, CHAN_AUTO, sound_talk2, 1, ATTN_IDLE, 0);
- else
- gi.sound (self, CHAN_AUTO, sound_talk, 1, ATTN_IDLE, 0);
- }
-
- void astronautTalk2(edict_t *self)
- {
- gi.sound (self, CHAN_AUTO, sound_talk3, 1, ATTN_IDLE, 0);
- }
-
- mframe_t astronaut_frames_talk [] =
- {
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, NULL,
- ai_charge, 0, astronautTalk2,
- ai_charge, 0, open_mouth,
- ai_charge, 0, close_mouth,
- ai_charge, 0, open_mouth,
- ai_charge, 0, close_mouth,
- ai_charge, 0, open_mouth,
- ai_charge, 0, close_mouth,
- ai_charge, 0, open_mouth,
- ai_charge, 0, close_mouth,
- ai_charge, 0, open_mouth,
- ai_charge, 0, close_mouth,
- ai_charge, 0, open_mouth,
- ai_charge, 0, close_mouth,
- ai_charge, 0, NULL
- };
- mmove_t astronaut_move_talk = {FRAME_talk01, FRAME_talk18, astronaut_frames_talk, astronaut_standstill};
-
- mframe_t astronaut_frames_talkstart [] =
- {
- ai_charge, 0, astronautTalk,
- ai_charge, 0, open_mouth,
- ai_charge, 0, close_mouth,
- ai_charge, 0, open_mouth,
- ai_charge, 0, close_mouth,
- ai_charge, 0, open_mouth,
- ai_charge, 0, close_mouth,
- ai_charge, 0, open_mouth,
- ai_charge, 0, close_mouth
- };
- mmove_t astronaut_move_talkstart = {FRAME_stand01, FRAME_stand09, astronaut_frames_talkstart, astronaut_talk};
-
- mframe_t astronaut_frames_signal [] =
- {
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL,
- ai_stand, 0, NULL
- };
-
- mmove_t astronaut_move_signal = {FRAME_signal01, FRAME_signal09, astronaut_frames_signal, astronaut_run};
-
- void astronaut_sight (edict_t *self, edict_t *other)
- {
- if (self->spawnflags & 1)
- self->monsterinfo.currentmove = &astronaut_move_run1;
- else
- {
- gi.sound (self, CHAN_VOICE, sound_sight, 1, ATTN_NORM, 0);
- self->monsterinfo.currentmove = &astronaut_move_signal;
- }
-
- }
-
- void astronaut_melee (edict_t *self)
- {
- self->monsterinfo.currentmove = &astronaut_move_talkstart;
- }
-
- void astronaut_talk (edict_t *self)
- {
- if (self->spawnflags & 1)
- self->monsterinfo.currentmove = &astronaut_move_standstill;
- else
- self->monsterinfo.currentmove = &astronaut_move_talk;
-
- }
-
- void astronaut_dead (edict_t *self)
- {
- VectorSet (self->mins, -16, -16, 0);
- VectorSet (self->maxs, 16, 16, 24);
- self->movetype = MOVETYPE_TOSS;
- self->svflags |= SVF_DEADMONSTER;
- self->nextthink = 0;
- gi.linkentity (self);
- }
-
-
- mframe_t astronaut_frames_death1 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
-
- };
- mmove_t astronaut_move_death1 = {FRAME_pain01, FRAME_pain07, astronaut_frames_death1, astronaut_dead};
-
-
- mframe_t astronaut_frames_death2 [] =
- {
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL,
- ai_move, 0, NULL
- };
- mmove_t astronaut_move_death2 = {FRAME_pain01, FRAME_pain07, astronaut_frames_death2, astronaut_dead};
-
-
- void astronaut_die (edict_t *self, edict_t *inflictor, edict_t *attacker, int damage, vec3_t point)
- {
- int n;
-
- if (self->health <= self->gib_health)
- {
- gi.sound (self, CHAN_VOICE, gi.soundindex ("misc/udeath.wav"), 1, ATTN_IDLE, 0);
- for (n= 0; n < 2; n++)
- ThrowGib (self, "models/objects/gibs/bone/tris.md2", damage, GIB_ORGANIC, EF_GIB);
- for (n= 0; n < 4; n++)
- ThrowGib (self, "models/objects/gibs/sm_meat/tris.md2", damage, GIB_ORGANIC, EF_GIB);
- if (!Q_stricmp(self->classname, "npc_redneck"))
- ThrowHead (self, "models/npc/redneck_dead/tris.md2", damage, GIB_ORGANIC, EF_GIB);
- else
- ThrowHead (self, "models/objects/gibs/head2/tris.md2", damage, GIB_ORGANIC, EF_GIB);
- self->deadflag = DEAD_DEAD;
- return;
- }
-
- if (self->deadflag == DEAD_DEAD)
- return;
-
- gi.sound (self, CHAN_VOICE, sound_die, 1, ATTN_NORM, 0);
- self->deadflag = DEAD_DEAD;
- self->takedamage = DAMAGE_YES;
-
- if (damage >= 50)
- self->monsterinfo.currentmove = &astronaut_move_death1;
- else
- self->monsterinfo.currentmove = &astronaut_move_death2;
- }
-
-
- /*QUAKED monster_astronaut (1 .5 0) (-16 -16 -24) (16 16 32) Ambush Trigger_Spawn Sight
- */
- void SP_npc_astronaut (edict_t *self)
- {
- if (deathmatch->value)
- {
- G_FreeEdict (self);
- return;
- }
-
- // pre-caches
- sound_pain = gi.soundindex ("astronaut/pain.wav");
- sound_die = gi.soundindex ("astronaut/death.wav");
- sound_idle = gi.soundindex ("astronaut/breathe.wav");
- sound_talk = gi.soundindex ("astronaut/talk.wav");
- sound_talk2 = gi.soundindex ("astronaut/talk2.wav");
- sound_talk3 = gi.soundindex ("astronaut/talk3.wav");
- sound_search = gi.soundindex ("astronaut/yell.wav");
- sound_sight = gi.soundindex ("astronaut/yell.wav");
-
- self->s.modelindex = gi.modelindex("models/npc/astronaut/tris.md2");
- self->s.modelindex2 = gi.modelindex ("models/npc/helmet/tris.md2");
-
- VectorSet (self->mins, -16, -16, 0);
- VectorSet (self->maxs, 16, 16, 56);
- self->movetype = MOVETYPE_STEP;
- self->solid = SOLID_BBOX;
-
- self->classname = "npc_astronaut";
-
- self->health = 150;
- self->gib_health = 40;
- self->mass = 150;
-
- self->pain = NULL;
- self->die = astronaut_die;
- self->monsterinfo.stand = astronaut_stand;
- self->monsterinfo.walk = astronaut_walk;
- self->monsterinfo.run = astronaut_run;
- self->monsterinfo.dodge = NULL;
- self->monsterinfo.attack = NULL;
- self->monsterinfo.melee = astronaut_melee;
- self->monsterinfo.sight = astronaut_sight;
- self->monsterinfo.search = astronaut_search;
-
- self->monsterinfo.currentmove = &astronaut_move_stand;
- self->monsterinfo.scale = MODEL_SCALE;
- self->monsterinfo.aiflags = AI_NPC;
-
- gi.linkentity (self);
-
- walkmonster_start (self);
- }
- void SP_npc_redneck (edict_t *self)
- {
- if (deathmatch->value)
- {
- G_FreeEdict (self);
- return;
- }
-
- // pre-caches
- sound_pain = gi.soundindex ("astronaut/pain.wav");
- sound_die = gi.soundindex ("astronaut/death.wav");
- sound_idle = gi.soundindex ("astronaut/breathe.wav");
- sound_talk = gi.soundindex ("redneck/talk.wav");
- sound_talk2 = gi.soundindex ("redneck/talk2.wav");
- sound_talk3 = gi.soundindex ("redneck/talk3.wav");
- sound_search = gi.soundindex ("astronaut/yell.wav");
- sound_sight = gi.soundindex ("astronaut/yell.wav");
-
- self->s.modelindex = gi.modelindex("models/npc/redneck/tris.md2");
-
- VectorSet (self->mins, -16, -16, 0);
- VectorSet (self->maxs, 16, 16, 56);
- self->movetype = MOVETYPE_STEP;
- self->solid = SOLID_BBOX;
-
- self->classname = "npc_redneck";
-
- self->max_health = 150;
- self->health = self->max_health;
- self->gib_health = 40;
- self->mass = 150;
-
- self->pain = NULL;
- self->die = astronaut_die;
- self->monsterinfo.stand = astronaut_stand;
- self->monsterinfo.walk = astronaut_stand;
- self->monsterinfo.run = redneck_run;
- self->monsterinfo.dodge = NULL;
- self->monsterinfo.attack = NULL;
- self->monsterinfo.melee = astronaut_talk;
- self->monsterinfo.sight = NULL;
- self->monsterinfo.search = astronaut_search;
-
- self->monsterinfo.currentmove = &astronaut_move_stand;
- self->monsterinfo.scale = MODEL_SCALE;
- self->monsterinfo.aiflags = AI_NPC;
-
- gi.linkentity (self);
-
- walkmonster_start (self);
- }
-